package com.jb.web.application;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Json{
    private Map hashmap = new HashMap(); 
    
    public Json(String key, String value) {
        hashmap.put(key, value);
    }
    
    public Json append(String key, String value) {
        hashmap.put(key, value);
        return this;
    }
    
    public String toString() {
        Iterator iter = hashmap.keySet().iterator();
        StringBuffer result = new StringBuffer("{");
        while(iter.hasNext()) {
            String key = (String) iter.next();
            String value = (String)hashmap.get(key);
            result.append("\"").append(key).append("\":\"").append(value).append(iter.hasNext()?"\",":"\"");
        }
        result.append("}");
        return result.toString();
    }
}
